import 'package:flutter/material.dart';
import 'package:stac/src/parsers/core/stac_widget_parser.dart';
import 'package:stac/src/parsers/foundation/alignment/stac_cross_axis_alignment_parser.dart';
import 'package:stac/src/parsers/foundation/alignment/stac_main_axis_alignment_parser.dart';
import 'package:stac/src/parsers/foundation/alignment/stac_main_axis_size_parser.dart';
import 'package:stac/src/parsers/foundation/layout/stac_vertical_direction_parser.dart';
import 'package:stac/src/parsers/foundation/text/stac_text_direction_parser.dart';
import 'package:stac_core/stac_core.dart';
import 'package:stac_framework/stac_framework.dart';

class StacRowParser extends StacParser<StacRow> {
  const StacRowParser();

  @override
  StacRow getModel(Map<String, dynamic> json) => StacRow.fromJson(json);

  @override
  String get type => StacRow().type;

  @override
  Widget parse(BuildContext context, StacRow model) {
    return Row(
        mainAxisAlignment:
            model.mainAxisAlignment?.parse ?? MainAxisAlignment.start,
        crossAxisAlignment:
            model.crossAxisAlignment?.parse ?? CrossAxisAlignment.center,
        mainAxisSize: model.mainAxisSize?.parse ?? MainAxisSize.max,
        textDirection: model.textDirection?.parse,
        verticalDirection:
            model.verticalDirection?.parse ?? VerticalDirection.down,
        // spacing: model.spacing ?? 0,
        children: model.children.parseList(context) ?? []);
  }
}
